package mic.hsacnu.util;

import android.content.Context;
import android.os.Handler;
import android.widget.Toast;

/**
 * 
 * @author mic.hsacnu STUDY-PROJECT-X Dr.Yoto Chang CPT
 *
 */

public class CustomToast {

    private static Toast mToast;
    private static Handler mHandler = new Handler();
    private static final int LENGTH_LONG=Toast.LENGTH_LONG;
    private static final int LENGTH_SHORT=Toast.LENGTH_SHORT;
    
    private static Runnable r = new Runnable() {
        public void run() {
            mToast.cancel();
            mToast=null;
        }
    };

    public static void makeText(Context mContext, String text, int duration) {
       
        mHandler.removeCallbacks(r);
        if (mToast != null)
            mToast.setText(text);
        else
            mToast = Toast.makeText(mContext, text, Toast.LENGTH_LONG);
        mHandler.postDelayed(r, duration);

        mToast.show();
    }
}
